<template>
  <div>
    <img src="../assets/login.png">
    <br>
    <h2>FZBB球鞋订单信息系统</h2>
    <div>
      <el-input style="width: 350px" placeholder="请输入账户名" v-model="username">
        <template slot="prepend">账号：</template>
      </el-input><br><br>
      <el-input style="width: 350px" placeholder="请输入密码" v-model="password">
        <template slot="prepend">密码：</template>
      </el-input><br><br>
      <el-button type="primary" @click="UserLogin">登录</el-button>
    </div>
  </div>

</template>

<script>
import axios from "axios";

export default {
  name: 'Login',
  data() {
    return {
      username: '',
      password: '',
    }
  },
  methods: {
    //点击登录按钮执行访问请求
    UserLogin() {
      //发送请求
      this.axios.post("/user/login", {
        username: this.username,
        password: this.password,
      }).then(res => {
        //setCookie
        console.log(res,'res');
        if (res.data.code == 200) {
          //成功后跳转页面
          this.$router.push({name: 'shoesList'})
        } else {
          alert(res.data.msg);
        }
      }).catch(err => {
        console.log(err, 'err');
      })
    },
    // userRogister() {
    //   //发送请求
    //   this.axios.post("/register", {
    //     username: this.username,
    //     password: this.password,
    //   }).then(res => {
    //     if (res.data.code == 200) {
    //       //成功后继续点登录
    //       alert(res.data.message);
    //     } else {
    //       alert(res.data.message);
    //     }
    //   })
    // },
  }
}
</script>

